﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace DownloadBook {
    public class SelectAllSupport {
        public static void Bind(TextBoxBase textBox) {
            textBox.KeyDown += TextBox_KeyDown;
        }
        public static void UnBind(TextBoxBase textBox) {
            textBox.KeyDown -= TextBox_KeyDown;
        }

        private static void TextBox_KeyDown(object sender, KeyEventArgs e) {
            if (e.KeyCode == Keys.A && e.Modifiers == Keys.Control) {
                TextBoxBase textBox = sender as TextBoxBase;
                if(textBox != null) {
                    textBox.SelectionStart = 0;
                    textBox.SelectionLength = textBox.TextLength;
                }
            }
        }
    }
}
